package test;

import java.util.ArrayList;
import java.util.List;

public class Demo345 {

    public static void main(String[] args) {

        String abced = reverseVowels("abe");
        System.out.println(abced);
    }

    public static String reverseVowels(String s) {

        char[] chars = s.toCharArray();
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < chars.length; i++) {
            char aCase = Character.toLowerCase(chars[i]);
            if (aCase == 'a' || aCase == 'e' || aCase == 'i' || aCase == 'o' || aCase == 'u') {
                list.add(i);
            }
        }

        int left = 0;
        int right = list.size() - 1;

        while (left < right) {
            char tem = chars[list.get(left)];
            chars[list.get(left)] = chars[list.get(right)];
            chars[list.get(right)] = tem;
            left++;
            right--;
        }

        return new String(chars);

    }
}
